<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id='app'>
        <form action="http://www.baidu.com">
            <div>
                <span>姓名</span>
                <span>
                    <!-- 单行文本 -->
                    <input type="text" v-model='uname'>
                </span>
            </div>
            <div>
                <span>性别</span>
                <span>
                    <!-- 单选框 -->
                    <input type="radio"  id="male" value="1" v-model='gender'>
                    <label for="male">男</label>
                    <input type="radio"  id="female" value="2" v-model='gender' >
                    <label for="female">女</label>
                </span>
            </div>
            <div>
                <span>爱好</span>
                <!-- 复选框 -->
                <input type="checkbox" id="ball" value="1" v-model="hobby">
                <label for="ball">篮球</label>
                <input type="checkbox" id="sing" value="2" v-model="hobby">
                <label for="sing">唱歌</label>
                <input type="checkbox" id="code" value="3" v-model="hobby">
                <label for="code">编程</label>
            </div>
            <div>
                <span>职业</span>
                <select v-model="occupation">
                    <!-- 下拉选项 -->
                    <option value="0">请选择职业</option>
                    <option value="1">教师</option>
                    <option value="2">软件</option>
                    <option value="3">律师</option>
                </select>
            </div>
            <div>
                <span>个人简介</span>
                <!-- 多行输入 -->
                <textarea cols="30" rows="10" v-model='desc'></textarea>
            </div>
            <div>
                <input type="submit" value="提交" @click.prevent='handle'>
            </div>
            <!-- 表单修饰符 -->
            <!-- number会把输入的值变成数字，而不是字符串 -->
            <input type="text" v-model.number="age">
            <!-- trim会去除空格 -->
            <input type="text" v-model.trim="info">
            <!-- lazy将input事件转化为change事件 ,input随时出发，change时失去1焦点时触发-->
            <input type="text" v-model.lazy='msg'>
        </form>
    </div>
    <script src="../js/vue.min.js"></script>
    <script>
        let vm = new Vue({
            el: '#app',
            data: {
                uname: 'lisi',
                gender: 1,
                hobby: ['1', '2'],
                occupation: 0,
                desc: 'hello',
                age: 12,
                info: '',
                msg: ''
            },
            methods: {
                handle: function() {
                    console.log(this.uname);
                    console.log(this.gender);
                    console.log(this.hobby.toString());
                    console.log(this.occupation);
                    console.log(this.desc);
                }
            }
        })
    </script>
</body>

</html>